package com.itheima.demo.test;

public class RunnableCLS implements Runnable {

    @Override
    public void run() {
        for (int i = 1; i <= 100; i++) {
            if (("曹操".equals(Thread.currentThread().getName()) && i == 20)){
                System.out.println("---曹操遇到了张飞,在打仗-----------");
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            } else if (("曹操".equals(Thread.currentThread().getName()) && i == 50)) {
                System.out.println("---曹操遇到了关羽,又开打了------------");
                try {
                    Thread.sleep(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
                System.out.println(Thread.currentThread().getName() + "已经跑了" + i + "公里!");
        }
    }
}
